<?php
require_once("lib/util.php");
require_once("lib/db.php");
require_once("lib/incident.php");
session_start();
$incident_id = $_GET["incident_id"];
connect();
$rating_count = total_rating($incident_id);
$incident= get_incident($incident_id);
$categories= get_categories();
$ratings= get_ratings();
$claimant_user_id= $_SESSION['logged_in_user'];
$last_rating_incident=$rating_count;
render("view_incident", array("incident" => $incident, "categories" => $categories, "ratings" => $ratings, "rating" => $rating_count));
close();

function get_incident($incident_id) {
	$incident_query= "SELECT * FROM incidents WHERE incident_id = ?"; 
	$incident = query ($incident_query, array($incident_id));
	return $incident[0] ;
}

function claim_incident( $incident_id, $claimant_user_id, $last_rating_incident){
$query="INSERT into claims (incident_id, claimant_user_id, last_rating_incident) VALUES (?,?,?)" ;
query ($query, array($incident_id, $claimant_user_id, $last_rating_incident));

}